package com.xiaoma.tpo.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.WdScore;

@Repository
public class WdScoreDao extends BaseDaoImpl<WdScore>{

    private static final Logger LOG = LoggerFactory.getLogger(WdScoreDao.class);
    
    @SuppressWarnings("unchecked")
    public List<WdScore> orderByScore(int planId, int groupId) {
//        String sql = "SELECT * FROM wd_score where wd_plan_id = ? and wd_group_id = ? GROUP BY score ORDER BY score desc";
        String sql = "SELECT * FROM wd_score where wd_plan_id = ? and wd_group_id = ? ORDER BY score desc";
        LOG.info("SQL:{}; planId={} ; groupId={}", sql, planId, groupId);
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(WdScore.class, getNameHandler()), planId, groupId);
        return (List<WdScore>)result;
    }
}
